const Sequelize = require('sequelize');
const dbConfig = require('./config/config').db_cloud;

// 创建实例
const sequelize = new Sequelize(dbConfig.database, dbConfig.user, dbConfig.password, {
    host: dbConfig.host,
    dialect: dbConfig.type,
    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000
    },
    define: {
        // timestamps: false,
        freezeTableName: true
    }
});

//测试数据库链接
sequelize.authenticate().then(function () {
    console.log("db connection success.");
}).catch(function (err) {
    //数据库连接失败时打印输出
    console.error(err);
    throw err;
});


exports.sequelize = sequelize
